package com.hnxxxy.sysmgr.mapper;

import com.hnxxxy.sysmgr.pojo.Dict;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author：张浩东
 * @Phone：15096207164
 * @QQ：1367048164
 * @E-mail：1367048164@qq.com
 * @date:2020年6月27日11:41:18
 */

@Mapper
public interface ISysDictionaryMapper {

//    @Insert(value = "INSERT INTO sys_log(user_id,time,url,`describe`,describe_type,type_name,ip,parameter,methods,abnormal) " +
//            "VALUES (#{userId}, #{time},#{url}, #{describe},#{describeType}, #{typeName},#{ip}, #{parameter}, #{methods}, #{abnormal})")
//    @Options(useGeneratedKeys=true, keyProperty="id",keyColumn = "id")
//    int insertSysLog(Log log);
//
    @Delete("delete from sys_dict where id = #{id}")
    int deleteSysDictionary(Integer id);

    @Select({"<script>",
            "select * from sys_dict ",
            "<where> ",
            "<if test='groupname!=null'>",
            "and groupname like concat('%',#{groupname},'%')",
            "</if>",
            "</where>",
            "</script>"})
    List<Dict> findAlSysDictionary(Dict dict);

    @Update({"<script>",
            "update sys_dict",
            "<set>",
            "<if test='dictid!=null'>",
            " dictid = #{dictid},",
            "</if>",
            "<if test='dictvalue!=null'>",
            "dictvalue=#{dictvalue},",
            "</if>",
            "<if test='groupid!=null'>",
            " groupid=#{groupid},",
            "</if>",
            "<if test='groupname!=null'>",
            "groupname=#{groupname},",
            "</if>",
            "<if test='tablename!=null'>",
            "tablename=#{tablename},",
            "</if>",
            "<if test='columnname!=null'>",
            "columnname=#{columnname},",
            "</if>",
            "<if test='remark!=null'>",
            "remark=#{remark},",
            "</if>",
            "<if test='type!=null'>",
            "type=#{type},",
            "</if>",
            "</set>",
            "where id=#{id}",
            "</script>"})
    int updateSysDictionary(Dict dict);

    @Insert({"insert into sys_dict (dictid, dictvalue, groupid, groupname,tablename,columnname,remark,type)" +
            " values (#{dictid},#{dictvalue},#{groupid},#{groupname},#{tablename},#{columnname},#{remark},#{type})"})
    int insertSysDictionary(Dict dict);
}
